package com.caiyi.financial.nirvana.sms.controller;

import com.caiyi.financial.nirvana.sms.entity.SmsRegisterUser;
import com.caiyi.financial.nirvana.sms.service.SmsRegisterUserService;
import com.youyu.common.api.Result;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 用户注册信息
 */
@Api(description = "用户注册管理用户接口")
@RequestMapping("sms/register")
@RestController
@CrossOrigin
public class RegisterUserController extends BaseController {

    @Autowired
    private SmsRegisterUserService smsRegisterUserService;

    @ApiOperation(value = "注册", notes = "注册")
    @PostMapping(value = "/addRegisterUser")
    public Result addRegisterUser(@RequestBody @ApiParam(name = "registerUser", value = "客户实体", required = true) SmsRegisterUser registerUser) {
        smsRegisterUserService.addRegisterUser(registerUser, session);
        return Result.ok();
    }


    @ApiOperation(value = "获取验证码", notes = "获取验证码")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "phone", value = "电话号码", required = true, dataType = "String", paramType = "query")
    })
    @PostMapping(value = "/getCode")
    public Result getCode(@RequestParam String phone) {
        smsRegisterUserService.sendCode(phone, session);
        return Result.ok();
    }

}
